
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define TARGET 100

char results[1000][100];
int result_count = 0;
void dfs(char *nums, int index, char *expression, long long current_sum, long long last_num) {
    if (index == strlen(nums)) {
        if (current_sum == TARGET) {
            strcpy(results[result_count], expression);
            result_count++;
        }
        return;
    }

    for (int i = index; i < strlen(nums); i++) {
        char num_str[10];
        strncpy(num_str, nums + index, i - index + 1);
        num_str[i - index + 1] = '\0';
        long long current_num = atoll(num_str);

        if (index == 0) {
            char new_expr[100];
            sprintf(new_expr, "%s", num_str);
            dfs(nums, i + 1, new_expr, current_sum + current_num, current_num);
        } else {
            char new_expr_add[100];
            sprintf(new_expr_add, "%s+%s", expression, num_str);
            dfs(nums, i + 1, new_expr_add, current_sum + current_num, current_num);

            char new_expr_sub[100];
            sprintf(new_expr_sub, "%s-%s", expression, num_str);
            dfs(nums, i + 1, new_expr_sub, current_sum - current_num, -current_num);
        }
    }
}

int main() {
    char nums[] = "987654321";
    char expression[100];

    dfs(nums, 0, expression, 0, 0);

    for (int i = 0; i < result_count; i++) {
        printf("%s = %d\n", results[i], TARGET);
    }

    return 0;
}


